<template>
  <div class="lawyer-layout">
    <!-- 顶部导航栏 -->
    <header class="top-nav">
      <div class="nav-container">
        <div class="nav-left">
          <h1 class="nav-title">律智助手2.0 - 律师端</h1>
        </div>
        
        <div class="nav-right">
          <div class="user-menu">
            <el-dropdown>
              <span class="user-info">
                <i class="fas fa-user-circle"></i>
                <span>{{ userStore.userInfo?.name || '律师' }}</span>
                <i class="fas fa-chevron-down ml-2"></i>
              </span>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item>
                    <i class="fas fa-user mr-2"></i>个人资料
                  </el-dropdown-item>
                  <el-dropdown-item>
                    <i class="fas fa-cog mr-2"></i>设置
                  </el-dropdown-item>
                  <el-dropdown-item divided @click="logout">
                    <i class="fas fa-sign-out-alt mr-2"></i>退出登录
                  </el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </div>
        </div>
      </div>
    </header>

    <div class="layout-container">
      <!-- 侧边栏导航 -->
      <aside class="sidebar">
        <nav class="sidebar-nav">
          <router-link to="/lawyer" class="nav-item" :class="{ active: $route.path === '/lawyer' }">
            <i class="fas fa-tachometer-alt"></i>
            <span>工作台</span>
          </router-link>
          
          <router-link to="/lawyer/cases" class="nav-item" :class="{ active: $route.path.startsWith('/lawyer/case') }">
            <i class="fas fa-folder-open"></i>
            <span>案件管理</span>
          </router-link>
          
          <router-link to="/lawyer/cases/library" class="nav-item" :class="{ active: $route.path.startsWith('/lawyer/cases/library') }">
            <i class="fas fa-book"></i>
            <span>案例库</span>
          </router-link>
          
          <router-link to="/lawyer/appraisal" class="nav-item" :class="{ active: $route.path.startsWith('/lawyer/appraisal') }">
            <i class="fas fa-stethoscope"></i>
            <span>鉴定管理</span>
          </router-link>
          
          <router-link to="/lawyer/appointments" class="nav-item" :class="{ active: $route.path.startsWith('/lawyer/appointments') }">
            <i class="fas fa-calendar-alt"></i>
            <span>预约管理</span>
          </router-link>
          
          <router-link to="/lawyer/templates" class="nav-item" :class="{ active: $route.path.startsWith('/lawyer/templates') }">
            <i class="fas fa-file-alt"></i>
            <span>文书模板</span>
          </router-link>
          
          <router-link to="/lawyer/intelligent-qa" class="nav-item" :class="{ active: $route.path.startsWith('/lawyer/intelligent-qa') }">
            <i class="fas fa-robot"></i>
            <span>智能问答</span>
          </router-link>
          
          <router-link to="/lawyer/statistics" class="nav-item" :class="{ active: $route.path.startsWith('/lawyer/statistics') }">
            <i class="fas fa-chart-bar"></i>
            <span>数据统计</span>
          </router-link>
        </nav>
      </aside>

      <!-- 主要内容区域 -->
      <main class="main-content">
        <router-view />
      </main>
    </div>
  </div>
</template>

<script>
import { useUserStore } from '@/stores/user'
import { useRouter } from 'vue-router'

export default {
  name: 'LawyerLayout',
  setup() {
    const userStore = useUserStore()
    const router = useRouter()
    
    const logout = () => {
      userStore.logout()
      router.push('/login')
    }
    
    return {
      userStore,
      logout
    }
  }
}
</script>

<style scoped>
.lawyer-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #f3f4f6;
}

.top-nav {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-container {
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-left .nav-title {
  font-size: 20px;
  font-weight: bold;
  color: white;
}

.nav-right {
  display: flex;
  align-items: center;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  color: white;
}

.user-info:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.user-info i:first-child {
  font-size: 20px;
}

.user-info span {
  font-size: 14px;
  font-weight: 500;
}

.layout-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 侧边栏样式 */
.sidebar {
  width: 240px;
  background: white;
  border-right: 1px solid #e5e7eb;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
  overflow-y: auto;
}

.sidebar-nav {
  padding: 20px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  color: #6b7280;
  text-decoration: none;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
  margin: 2px 0;
}

.nav-item:hover {
  color: #3b82f6;
  background-color: #f8fafc;
  border-left-color: #d1d5db;
}

.nav-item.active {
  color: #3b82f6;
  background-color: #eff6ff;
  border-left-color: #3b82f6;
  font-weight: 600;
}

.nav-item i {
  font-size: 16px;
  margin-right: 12px;
  width: 20px;
  text-align: center;
}

.nav-item span {
  font-size: 14px;
}

/* 主内容区域 */
.main-content {
  flex: 1;
  overflow-y: auto;
  background-color: #f9fafb;
  padding: 0;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }
  
  .nav-container {
    padding: 0 20px;
  }
}

@media (max-width: 768px) {
  .layout-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
  }
  
  .sidebar-nav {
    display: flex;
    overflow-x: auto;
    padding: 8px 16px;
  }
  
  .nav-item {
    flex-shrink: 0;
    padding: 8px 16px;
    margin: 0 4px;
    border-left: none;
    border-bottom: 3px solid transparent;
    border-radius: 8px;
  }
  
  .nav-item.active {
    border-left: none;
    border-bottom-color: #3b82f6;
  }
  
  .nav-item:hover {
    border-left: none;
    border-bottom-color: #d1d5db;
  }
}
</style> 